<link rel="stylesheet" href="../js/lay-module/step-lay/step.css" media="all">
<div class="layuimini-container layuimini-page-anim">
    <div class="layuimini-main">

        <div class="layui-fluid">
            <div class="layui-card">
                <div class="layui-card-body" style="padding-top: 40px;">
                    <div class="layui-carousel" id="stepForm" lay-filter="stepForm" style="margin: 0 auto;">
                        <div carousel-item>
                            <div>
                        <!--第一个表单-->
                                <form class="layui-form" lay-filter="formTest" style="margin: 0 auto;max-width: 460px;padding-top: 40px;" action="" >
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">客户姓名:</label>
                                        <div class="layui-input-block">
                                            <input type="text" placeholder="请填写客户姓名" class="layui-input" id="xsbCName" name="xsbCName"  lay-filter="xsbCName"  lay-verify="required" />
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">客户电话:</label>
                                        <div class="layui-input-block">
                                            <input type="text" placeholder="请填写客户电话" value="" class="layui-input"  id="xsbCPhone" name="xsbCPhone"  lay-filter="xsbCPhone"  lay-verify="required|phone"  >
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">客户公司:</label>
                                        <div class="layui-input-block">
                                            <input type="text" placeholder="请填写客户公司名称" class="layui-input"  name="xsbCCompany"  id="xsbCCompany" lay-filter="xsbCCompany" />
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">备注说明:</label>
                                        <div class="layui-input-block">
                                            <textarea placeholder="入款备注" value="" class="layui-textarea"></textarea>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-input-block">
                                            <button class="layui-btn" lay-submit="" lay-filter="formStep">
                                                &emsp;下一步&emsp;
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <div>
                                <form class="layui-form" lay-filter="formTest1" style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">计划编号:</label>
                                        <div class="layui-input-block">
                                            <input type="text" placeholder="请按照(plan+日期)填写" class="layui-input" name="xsbDNo" lay-filter="xsbDNo" lay-verify="required"  />
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">计划名称:</label>
                                        <div class="layui-input-block">
                                            <input type="text" placeholder="请填写计划名称" class="layui-input" name="xsbDName" lay-filter="xsbDName" lay-verify="required"  />
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">客户名称:</label>
                                        <div class="layui-input-block">
                                            <input type="text" placeholder="请填写客户名称" class="layui-input"  name="client.xsbCName" lay-filter="xsbCName"  lay-verify="required" />
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">计划类型:</label>
                                        <div class="layui-input-block">
                                            <input type="text" placeholder="请填写计划类型" class="layui-input" name="xsbDType" lay-filter="xsbDType" />
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">日期时间选择器</label>
                                        <div class="layui-input-block">
                                            <input type="text" class="layui-input" id="test5" name="xsbDTime" lay-filter="xsbDTime" placeholder="yyyy-MM-dd HH:mm:ss">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">最小金额:</label>
                                        <div class="layui-input-block">
                                            <input type="text" placeholder="请填写计划最小金额" class="layui-input" name="xsbDMinmoney" lay-filter="xsbDMinmoney" lay-verify="number"  />
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">总金额:</label>
                                        <div class="layui-input-block">
                                            <input type="text" placeholder="请填写计划总金额" class="layui-input" name="xsbDMaxmoney" lay-filter="xsbDMaxmoney" lay-verify="number"  />
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">备注说明:</label>
                                        <div class="layui-input-block">
                                            <textarea placeholder="客户要求" value="" class="layui-textarea"></textarea>
                                        </div>
                                    </div>

                                    <div class="layui-form-item">
                                        <div class="layui-input-block">
                                            <button type="button" class="layui-btn layui-btn-primary pre">上一步</button>
                                            <button class="layui-btn" lay-submit lay-filter="formStep2">
                                                &emsp;确认创建计划表?&emsp;
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <div>
                                <div style="text-align: center;margin-top: 90px;">
                                    <i class="layui-icon layui-circle"
                                       style="color: white;font-size:30px;font-weight:bold;background: #52C41A;padding: 20px;line-height: 80px;">&#xe605;</i>
                                    <div style="font-size: 24px;color: #333;font-weight: 500;margin-top: 30px;">
                                        创建成功
                                    </div>
                                    <div style="font-size: 14px;color: #666;margin-top: 20px;">等待审批</div>
                                </div>
                                <div style="text-align: center;margin-top: 50px;">
                                    <button class="layui-btn next">再次创建</button>
                                    <button class="layui-btn layui-btn-primary">查看审批</button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <hr>
                    <div style="color: #666;margin-top: 30px;margin-bottom: 40px;padding-left: 30px;">
                        <h3>说明</h3><br>
                        <p style="color: red">如果有问题，请联系你的负责人</p>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>
<script>
    layui.use(['form', 'step','laydate'], function () {
        var $ = layui.$,
            form = layui.form,
            step = layui.step;
            laydate = layui.laydate;
        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();
        laydate.render({
            elem: '#test5'
            ,type: 'datetime'
        });

        step.render({
            elem: '#stepForm',
            filter: 'stepForm',
            width: '100%', //设置容器宽度
            stepWidth: '750px',
            height: '650px',
            stepItems: [{
                title: '填写客户信息'
            }, {
                title: '填写计划书信息'
            }, {
                title: '完成'
            }]
        });


        form.on('submit(formStep)', function (data) {
            // var data2=JSON.stringify(data.field);

            var data1 = data.field;
            // console.log(data2);
            console.log(data1);
            $.ajax({
                url: "/addClient",
                type:'post',
                data:data1,
                dataType:"json"
            });

            // layer.alert(data2);
            //给下一个表单赋值
            form.val("formTest1", { //formTest1 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
                "client.xsbCName": data1.xsbCName // "name": "value"
            });
            step.next('#stepForm');
            return false;
        });

        form.on('submit(formStep2)', function (data) {


            var data1 = data.field;
            // console.log(data2);
            console.log(data1);
            $.ajax({
                url: "/addPlan",
                type:'post',
                data:data1,
                dataType:"json"
            });
            step.next('#stepForm');
            return false;
        });

        $('.pre').click(function () {
            step.pre('#stepForm');
        });

        $('.next').click(function () {
            step.next('#stepForm');
        });
    })
</script>
